home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / APW.SC / SC05Cust.Wind / RR.Wnd.asm1 < prev    next >
Encoding:
Text File  |  1990-06-24  |  27.6 KB  |  784 lines  |  [TEXT/pdos]

  1. *******************************************************************************
  2. *
  3. * RoundRect Window
  4. *
  5. * (C)  Copyright Apple Computer, Inc. 1988-1990
  6. * All rights reserved.
  7. *
  8. * Developer Technical Support Apple II Sample Code
  9. *
  10. * by Keith Rollin
  11. *
  12. * This file contains the definition procedure (defProc) for a custom window.
  13. * This window acts like a fairly normal, but limited, window, and has the
  14. * following features:
  15. *
  16. *     - The corners are curved. The radius of the corners can be specified.
  17. *     - It always has a title bar, which always has a solid background color
  18. *       and title in it. The titlebar redraws itself in response to being
  19. *       activated and deactivated.
  20. *     - A GoAway box can optionally be included in the title bar. The zoom
  21. *       box is not drawn or supported.
  22. *     - There are no infobars or frame controls (like scrollbars).
  23. *     - A color table can be provided, or a default color table can be used.
  24. *     - The window can be dragged and grown.
  25. *     - TaskMaster is supported.
  26. *
  27. *******************************************************************************
  28.  
  29.                     EJECT
  30. *******************************************************************************
  31. *
  32. RRectDefProcData    data
  33. *
  34. * Description:      Equates and variables used by the RoundRect Window defProc.
  35. *
  36. *
  37. *******************************************************************************
  38.  
  39. ; stack/direct page frame. These equates are used to access information that
  40. ; is passed to the window DefProc on the stack.
  41.  
  42.  
  43.                     DefineStack
  44.  
  45. OrigD               word                ; saved Direct Page register
  46. OrigB               byte                ; saved Data Bank register
  47. work                long                ; a LONG of workspace
  48. workRgn             long                ; a LONG of workspace
  49. returnAddr          block 3             ; RTL address
  50. param               long                ; operation specific parameter
  51. theWindow           long                ; This is NOT a pointer to the window.
  52. *                                       ; This is a pointer to a window record.
  53. *                                       ; This means that it points to
  54. *                                       ; owNext, not the grafPort part of
  55. *                                       ; a window record!!
  56. operation           word                ; operation to perform
  57. windGlobals         long                ; pointer to handy values
  58. result              long                ; place to store operation result
  59.  
  60. ;
  61. ; Window Globals table
  62. ;
  63. lineW               equ 0               ; width of vertical lines
  64. titleHeight         equ lineW+2         ; Height of standard title bar
  65. titleYPos           equ titleHeight+2   ; Y offset for title in std. titlebar
  66. closeHeight         equ titleYPos+2     ; height of close icon.
  67. closeWidth          equ closeHeight+2   ; width of close icon.
  68. defWindClr          equ closeWidth+2    ; pointer to default color table
  69. windIconFont        equ defWindClr+4    ; handle to current window icon font
  70. screenMode          equ windIconFont+4  ; TRUE if 640 mode, FALSE if 320
  71. pattern             equ screenMode+2    ; Temporary pattern buffer
  72. callerDPage         equ pattern+32      ; DP of last caller to TaskMaster
  73. callerDataB         equ callerDPage+2   ; DBR of last caller to TaskMaster
  74.  
  75. ;
  76. ; NewWindow Parameter list
  77. ;
  78.                     DSect 0
  79. wParamID            word                ; should be zero for custom windows
  80. wMe                 long                ; address of customProc
  81. wFrameBits          word                ; flags that determine window type
  82. wPosition           block 8             ; used as portRect for contents
  83. wPlane              long                ; window Plane
  84. wStorage            long                ; storage for the window record
  85. ; These 2 are copied in one pass. Keep together and in this order.
  86. wRefCon             long                ; refCon
  87. wContDraw           long                ; routine that draw the contents
  88. ; Everything past here is copied after the wFrame field of the Window Record.
  89. wCustom             block 0             ; start of custom information section
  90. wTitle              long                ; pointer to window's title
  91. wColorTable         long                ; pointer to color table
  92. wRV                 word                ; vertical radius of corners
  93. wRH                 word                ; horizontal radius of corners
  94. wEnd                block 0
  95.  
  96. ;
  97. ; My extensions for this custom window
  98. ;
  99.                     DSect windSize
  100. xowTitle            long                ; pointer to window's title
  101. xowColorPtr         long                ; pointer to our color table (if any)
  102. xowRV               word                ; vertical radius of corners
  103. xowRH               word                ; horizontal radius of corners
  104. xowEnd              block 0
  105.  
  106. ;
  107. ; Position of the GoAway box
  108. ;
  109. GAX                 equ 10
  110. GAY                 equ 2
  111.  
  112. ;
  113. ; Scratch areas
  114. ;
  115. contRect            ds 8
  116. strucRect           ds 8
  117. pRect               ds 8
  118.  
  119.                     end
  120.  
  121.  
  122.                     EJECT
  123. *******************************************************************************
  124. *
  125. RRectDefProc        start
  126. *
  127. * Description:      Main Procedure for the RoundRect custom window definition.
  128. *                   This routine creates a suitable environment for us (saves
  129. *                   the old Direct Page and Data Bank registers and makes us
  130. *                   some new ones), calls the appropriate routine based on
  131. *                   the value of 'operation', and returns to the Window
  132. *                   Manager with the Carry bit and Y register set correctly.
  133. *
  134. *
  135. * Inputs:
  136. *                   On entry, the stack contains the following values:
  137. *
  138. *                   -------- previous contents --------
  139. *                   LONG  result        space for result
  140. *                   LONG  windGlobals   pointer to WMgr globals
  141. *                   WORD  operation     operation number to be performed
  142. *                   LONG  theWindow     ptr to window's record
  143. *                   LONG  param         additional parameter for some ops.
  144. *                   3 Bytes             RTL Address
  145. *                         <------------ Stack Pointer
  146. *
  147. * Outputs:          Carry = clear if no error
  148. *                   Carry = set if error, and Y has error number.
  149. *
  150. * External Refs:
  151. *                   Import rrDraw
  152. *                   Import rrHit
  153. *                   Import rrCalcRgns
  154. *                   Import rrNew
  155. *                   Import rrDispose
  156. *                   Import rrGetDrag
  157. *                   Import rrGrowFrame
  158. *                   Import rrRecSize
  159. *                   Import rrPosition
  160. *                   Import rrBehind
  161. *                   Import rrCallDefProc
  162. *
  163. * Entry Points:     NONE
  164. *
  165. *******************************************************************************
  166.                     using RRectDefProcData
  167. wMaxTask            equ 10
  168.  
  169. ; The first thing we do is get a little Direct Page space by using the stack.
  170. ; First, push on some scratch space onto the stack, then save the old values
  171. ; of the Data Bank Register and the Direct Page Register. Set the Data Bank
  172. ; Register to the same value as the Program Bank Register, and then transfer
  173. ; the Stack Pointer to the Direct Page Register. This gives us a stack and
  174. ; Direct Page that looks like this:
  175. ;
  176. ; Direct Page location  SIZE  What it is
  177. ;                   25  LONG  result
  178. ;                   21  LONG  windGlobals
  179. ;                   19  WORD  operation
  180. ;                   15  LONG  theWindow
  181. ;                   11  LONG  param
  182. ;                    8  3 Bytes RTL Address
  183. ;                    4  LONG  workspace
  184. ;                    3  BYTE  old Data Bank Register
  185. ;                    1  WORD  old Direct Page Register
  186. ;                           <--- stack pointer
  187.  
  188.                     pha                 ; Push on 8 bytes of workspace.
  189.                     pha
  190.                     pha
  191.                     pha
  192.  
  193.                     phb                 ; Save the data bank register
  194.                     phd                 ; Save the direct page register
  195.  
  196. ; Set the Data Bank register to the Program Bank register. This allows short
  197. ; (2 byte) addressing, as opposed to the 3 byte addressing we would have had
  198. ; to use if the Data Bank register were set to some unknown value.
  199.  
  200.                     phk                 ; Set up my own DBR
  201.                     plb
  202.  
  203. ; Set the direct page to the stack. This lets us use some of the values passed
  204. ; to us as 'zero-page' pointers (like theWindow).
  205.  
  206.                     tsc                 ; Set up my own Direct Page
  207.                     tcd
  208.  
  209. ; Zero out 'result' as default.
  210.  
  211.                     stz <result         ; zero this out to start with
  212.                     stz <result+2
  213.  
  214. ; Find out which operation to perform, check its range, and, if it is OK,
  215. ; convert it to an index into a jump table. Execute the routine.
  216.  
  217.                     lda <operation
  218.                     cmp #wMaxTask+1
  219.                     bcs OutOfRange
  220.  
  221.                     asl a
  222.                     tax
  223.                     jsr (opTable,x)
  224.  
  225. ; The operation has been carried out. Strip the parameters off of the stack
  226. ; and move the return address up, making sure to leave the 'result'. Gotta be
  227. ; careful to preserve the carry flag here!!!
  228.  
  229. OutOfRange          lda <returnAddr     ; move the return address up
  230.                     sta <result-3
  231.                     lda <returnAddr+1
  232.                     sta <result-2
  233.  
  234.                     tsc                 ; get the stack ptr so we can change it
  235.  
  236.                     pld                 ; restore the DP and DBR
  237.                     plb
  238.  
  239.                     php                 ; save the state of the carry
  240.                     clc                 ; fudge the stack pointer
  241.                     adc #result-4
  242.                     plp                 ; restore the carry state
  243.                     tcs                 ; point the stack pointer to the return
  244. *                                       ; address we moved up
  245.  
  246.                     rtl                 ; back to the window manager
  247.  
  248. opTable             dc i2'rrDraw'       ; Draw the specified part
  249.                     dc i2'rrHit'        ; determine where we hit
  250.                     dc i2'rrCalcRgns'   ; Calculate Struc and Content Regions
  251.                     dc i2'rrNew'        ; Perform initialization
  252.                     dc i2'rrDispose'    ; Close window
  253.                     dc i2'rrGetDrag'    ; Dragging to be done
  254.                     dc i2'rrGrowFrame'  ; Grow the frame
  255.                     dc i2'rrRecSize'    ; Return our window record size
  256.                     dc i2'rrPosition'   ; Return window pos/size
  257.                     dc i2'rrBehind'     ; Return plane placement
  258.                     dc i2'rrCallDefProc'                    ; Perform special stuff
  259.  
  260.                     end
  261.  
  262.                     EJECT
  263. *******************************************************************************
  264. *
  265. rrDraw              start
  266. *
  267. * Description:      Draw the specified part of the window.
  268. *
  269. * We draw the window frame (part $0000) in the following way:
  270. *
  271. *   1. Save various QuickDraw states that we will be changing.
  272. *   2. Set the pen to normal.
  273. *   3. Get the rectangle of our structure region.
  274. *   4. Get a pointer to the color table we'll be using.
  275. *   5. Set the color of the title bar (background). This changes
  276. *      depending on whether the window is active or not.
  277. *   6. Draw the title bar with PaintRect.
  278. *   7. Set the color to the outline color.
  279. *   8. Draw the main part of the frame with FrameRRect.
  280. *   9. Draw the line that divides the title bar from the content region.
  281. *  10. Calculate and position the pen for the string title.
  282. *  11. Set the color for the title. Again, this changes depending on
  283. *      whether the window is active or not.
  284. *  12. If the window is active, call the standalone routine that draws
  285. *      the close box (part $0001).
  286. *  13. Restore the QuickDraw state we saved and return.
  287. *
  288. *
  289. * Inputs:           param  = specification of part to draw:
  290. *
  291. *                        0 = draw the entire window
  292. *                        1 = draw the go-away region
  293. *                        2 = draw the zoom region
  294. *                        3 = draw the info bar
  295. *
  296. *                   If the high bit of param is set, then draw the item in
  297. *                   its highlighted state. Note: to determine whether to draw
  298. *                   a window titlebar in its active or inactive state, look
  299. *                   at the fHilite flag in the window record.
  300. *
  301. * Outputs:          result = zero
  302. *                   carry  = clear
  303. *
  304. * External Refs:    NONE
  305. *
  306. * Entry Points:
  307. *                   entry drawFrame     ; called by rrSetxxxx routines when a
  308. *                                       ; field is changed.
  309. *
  310. *******************************************************************************
  311.                     using RRectDefProcData
  312.  
  313.                     lda <param          ; find out which part to draw
  314.                     asl a               ; turn into an index into a jump table
  315.                     tax
  316.                     jsr (partToDraw,x)
  317.  
  318.                     clc
  319.                     rts
  320.  
  321. partToDraw          dc i2'drawFrame'
  322.                     dc i2'drawGoAway'
  323.                     dc i2'drawZoomBox'
  324.                     dc i2'drawInfoBar'
  325.  
  326. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  327. ;
  328. ; Draws the entire frame of a window. This includes the go-away box and any
  329. ; other parts of the frame that you may implement (like a zoom box, an
  330. ; infobar, scrollbars, grow box, etc.
  331. ;
  332. drawFrame           entry
  333.                     pha                 ; save the text mode (on the stack!)
  334.                     _GetTextMode
  335.  
  336.                     pha
  337.                     _GetPenMode
  338.  
  339.                     pha                 ; and the color (on the stack!)
  340.                     _GetForeColor
  341.  
  342.                     _PenNormal
  343.  
  344.                     jsr GetStrucRect
  345.  
  346.                     jsr SetColorTable   ; put ptr to a color table into 'work'
  347.  
  348. ;
  349. ; Now draw the background of the window. Set the color to the backbround color
  350. ; in the color table, then do a PaintRect to draw it all.
  351. ;
  352.                     jsr SetBGColor
  353.  
  354.                     ldy #6              ;Make a local rectangle that
  355. aa                  lda strucRect,y     ;encompasses the title bar.
  356.                     sta pRect,y
  357.                     dey
  358.                     dey
  359.                     bpl aa
  360.                     ldy #titleHeight
  361.                     clc
  362.                     adc [<windGlobals],y
  363.                     dec a
  364.                     sta pRect+4
  365.                     inc pRect
  366.  
  367.                     pha                 ;Make a rectangular region the
  368.                     pha                 ;same size as this rectangle.
  369.                     _NewRgn
  370.                     lda 1,s
  371.                     sta <workRgn
  372.                     lda 3,s
  373.                     sta <workRgn+2
  374.                     pea pRect|-16
  375.                     pea pRect
  376.                     _RectRgn
  377.  
  378.                     stz offset
  379.                     stz offset+2
  380.                     PushLong #offset
  381.                     _LocalToGlobal
  382.                     pei <workRgn+2
  383.                     pei <workRgn
  384.                     lda offset+2
  385.                     pha
  386.                     lda offset
  387.                     pha
  388.                     _OffsetRgn
  389.  
  390.                     ldy #owStrucRgn+2   ; get the handle from the window record
  391.                     lda [<theWindow],y
  392.                     pha
  393.                     dey
  394.                     dey
  395.                     lda [<theWindow],y
  396.                     pha
  397.                     pei <workRgn+2
  398.                     pei <workRgn
  399.                     pei <workRgn+2
  400.                     pei <workRgn
  401.                     _SectRgn
  402.  
  403.                     stz offset
  404.                     stz offset+2
  405.                     PushLong #offset
  406.                     _GlobalToLocal
  407.                     pei <workRgn+2
  408.                     pei <workRgn
  409.                     lda offset+2
  410.                     pha
  411.                     lda offset
  412.                     pha
  413.                     _OffsetRgn
  414.  
  415.                     pei <workRgn+2
  416.                     pei <workRgn
  417.                     pea 2
  418.                     pea 0
  419.                     _InsetRgn
  420.  
  421.                     pei <workRgn+2
  422.                     pei <workRgn
  423.                     _PaintRgn
  424.  
  425. ;
  426. ; Draw the frame. Set the outline color and the Pen Width, and use
  427. ; 'strucRect' to call FrameRRect.
  428. ;
  429.  
  430.                     ldy #oframeColor    ; set the outline color
  431.                     lda [<work],y       ; in bits 7-4
  432.                     lsr a
  433.                     lsr a
  434.                     lsr a
  435.                     lsr a
  436.                     and #%00001111
  437.                     pha
  438.                     _SetSolidPenPat
  439.  
  440.                     ldy #lineW          ; now set up the pen size by using the
  441.                     lda [<windGlobals],y ; pen width value the Window Manager
  442.                     pha                 ; passes to us in the Globals section.
  443.                     PushWord #1         ; hardcode the height to 1
  444.                     _SetPenSize
  445.  
  446.                     PushLong #strucRect ; now draw the entire frame
  447.                     ldy #xowRH          ; these are the radii of the corners
  448.                     lda [<theWindow],y
  449.                     pha
  450.                     ldy #xowRV
  451.                     lda [<theWindow],y
  452.                     pha
  453.                     _FrameRRect
  454.  
  455.                     lda strucRect       ; calculate the VPos of the dividing
  456.                     ldy #titleHeight    ; line.
  457.                     clc
  458.                     adc [<windGlobals],y
  459.                     dec a
  460.  
  461.                     ldx strucRect+6     ; push on first X/Y coordinate of a
  462.                     dex                 ; moveTo/lineTo sequence
  463.                     dex
  464.                     phx
  465.                     pha
  466.  
  467.                     ldx strucRect+2     ; the other X/Y coordinate
  468.                     phx
  469.                     pha
  470.  
  471.                     _MoveTo             ; draw the dividing line
  472.                     _LineTo
  473.  
  474. ; Position and draw the title. Use 'oTitleColor' in the color table.
  475.  
  476.                     jsr GetStringXPos
  477.  
  478.                     PushWord XPos       ; Next position to draw the title
  479.                     ldy #titleYPos      ; let the window manager tell us its
  480.                     PushWord [<windGlobals],y ; vertical position.
  481.                     _Moveto
  482.  
  483.                     PushWord #modeForeCopy ; set mode to our liking
  484.                     _SetTextMode
  485.  
  486.                     jsr SetTitleColor   ; set up colors accordingly
  487.  
  488.                     PushLong TitlePtr   ; draw the title
  489.                     _DrawString
  490.  
  491.                     jsr WindowActive    ; Is the window active? If so
  492.                     beq noGoAway        ; don't grow goAway box
  493.  
  494.                     ldy #owFrame        ; does this window have a close
  495.                     lda [<theWindow],y  ; box?
  496.                     and #fClose
  497.                     beq noGoAway        ; no so don't draw one.
  498.  
  499.                     jsr drawGoAway
  500.  
  501. noGoAway            ANOP
  502.                     _SetForeColor       ; restore the color and the mode
  503.                     _SetPenMode
  504.                     _SetTextMode
  505.  
  506.                     rts
  507.  
  508. offset              ds 4
  509.  
  510. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  511. ;
  512. ; Draw JUST the go-away box in the frame. This will ususally be called when
  513. ; TrakGoAway needs to (un)hilite it, but it could really be called at any
  514. ; time.
  515.  
  516. drawGoAway          ANOP
  517.                     jsr SetColorTable   ; get a pointer to color table
  518.  
  519.                     pha                 ; save the text mode (on the stack!)
  520.                     _GetTextMode
  521.  
  522.                     pha                 ; and the color (on the stack!)
  523.                     _GetForeColor
  524.  
  525.                     pha                 ; and the color (on the stack!)
  526.                     _GetBackColor
  527.  
  528.                     PushWord #modeCopy  ; set mode to our liking
  529.                     _SetTextMode
  530.  
  531.                     ldy #otitleColor    ; set the text color
  532.                     lda [<work],y
  533.                     and #%00001111
  534.                     pha
  535.                     _SetForeColor
  536.  
  537.                     ldy #otBarColor     ; set the background
  538.                     lda [<work],y
  539.                     and #%00001111
  540.                     pha
  541.                     _SetBackColor
  542.  
  543.                     pha                 ; save the current font so that we
  544.                     pha                 ; can switch to the Window Manager
  545.                     _GetFont            ; icon font.
  546.                     PullLong OldFont
  547.  
  548.                     ldy #windIconFont+2 ; Get the Window icons from the
  549.                     PushWord [<windGlobals],y ; window globals area
  550.                     dey
  551.                     dey
  552.                     PushWord [<windGlobals],y
  553.                     _SetFont
  554.  
  555.                     PushWord #GAX       ; X position for goaway
  556.                     PushWord #GAY       ; Y ditto
  557.                     _MoveTo
  558.  
  559.                     lda <param+2        ; how are we to draw this?
  560.                     bmi DrawHilited
  561.  
  562.                     PushWord #0         ; draw a normal go-away box
  563.                     bra DrawIt
  564. DrawHilited         PushWord #1         ; draw a hilited go-away box
  565. DrawIt              _DrawChar
  566.  
  567.                     PushLong OldFont    ; put the old font back
  568.                     _SetFont
  569.  
  570.                     _SetBackColor       ; restore the mode and color
  571.                     _SetForeColor       ; restore the mode and color
  572.                     _SetTextMode
  573.  
  574.                     rts
  575.  
  576. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  577. ;
  578. ; These aren't implemented.
  579.  
  580. drawZoomBox         ANOP
  581. drawInfoBar         ANOP
  582.                     rts
  583.  
  584. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  585. ;
  586. ; Utility routines for DrawFrame
  587. ;
  588. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  589. ;
  590. ; Check the window record to see if there is a pointer to a
  591. ; color table there. If there is one, put it into 'work' for
  592. ; later use. If there isn't one, use the default provided us
  593. ; by the Window Manager in WindGlobals.
  594. ;
  595.  
  596. SetColorTable       ANOP
  597.                     ldy #xowColorPtr    ; set what is pointed to in the
  598.                     lda [<theWindow],y  ; window record. Store it into
  599.                     sta <work           ; 'work' assuming that it is not
  600.                     iny                 ; zero.
  601.                     iny
  602.                     lda [<theWindow],y
  603.                     sta <work+2
  604.                     ora <work           ; is it really zero?
  605.                     bne done            ; no, so use it.
  606.  
  607.                     ldy #defWindClr     ; yes, it is zero. Use the defaults.
  608.                     lda [<windGlobals],y
  609.                     sta <work
  610.                     iny
  611.                     iny
  612.                     lda [<windGlobals],y
  613.                     sta <work+2
  614. done                ANOP
  615.                     rts
  616.  
  617.  
  618. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  619. ;
  620. ; Do some math to determine where the title string will go. We use
  621. ; the formula: (midpoint of the window) - (half the length of the string)
  622. ;
  623. ;     (left + (right - left) / 2)) - (StringWidth) / 2
  624. ;
  625. ; which reduces to:
  626. ;
  627. ;     (left + right - StringWidth) / 2
  628. ;
  629.  
  630. GetStringXPos       ANOP
  631.                     ldy #xowTitle+2     ; get the offset in the record to the
  632.                     lda [<theWindow],y  ; title
  633.                     sta TitlePtr+2
  634.                     dey
  635.                     dey
  636.                     lda [<theWindow],y
  637.                     sta TitlePtr
  638.  
  639.                     pha                 ; find out how long it is to center it
  640.                     PushLong TitlePtr
  641.                     _StringWidth
  642.                     PullWord XPos       ; save it here for a little bit
  643. ;
  644. ; now find the left edge of the string by using the equation:
  645. ;  (windLeft+windRight-strLen)/2
  646. ;
  647.                     ldy #oport+oportRect+6 ; get the right edge of the window
  648.                     lda [<theWindow],y
  649.                     dey
  650.                     dey
  651.                     dey
  652.                     dey
  653.                     clc
  654.                     adc [<theWindow],y  ; add the right edge
  655.                     sec
  656.                     sbc XPos            ; subtract the string's width
  657.                     lsr a               ; divide it all by two
  658.                     sta XPos            ; save the left edge starting position
  659.                     rts
  660.  
  661.  
  662.  
  663. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  664. ;
  665. ; Get the boundsRect of the StrucRgn in the window record. This allows us
  666. ; to do a simple FrameRRect(portRect), which is a lot faster for drawing
  667. ; the frame than FrameRgn(strucRgn).
  668.  
  669. GetStrucRect        Entry               ; also called from myDragRoutine
  670.                     ldy #owStrucRgn     ; get the handle from the window record
  671.                     lda [<theWindow],y
  672.                     sta <work
  673.                     iny
  674.                     iny
  675.                     lda [<theWindow],y
  676.                     sta <work+2
  677.  
  678.                     ldy #2              ; now dereference into a pointer
  679.                     lda [<work],y
  680.                     tax
  681.                     lda [<work]
  682.                     sta <work
  683.                     stx <work+2
  684.  
  685.                     ldy #2+6            ; copy the rgnBBox into pRect
  686.                     ldx #6
  687. loop                ANOP
  688.                     lda [<work],y
  689.                     sta strucRect,x
  690.                     dey
  691.                     dey
  692.                     dex
  693.                     dex
  694.                     bpl loop
  695.  
  696.                     PushLong #strucRect
  697.                     _GlobalToLocal
  698.  
  699.                     PushLong #strucRect+4
  700.                     _GlobalToLocal
  701.                     rts
  702.  
  703. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  704. ;
  705. ; Find the state of the window (whether it's active or not), and set
  706. ; the BackGround color of the Title bar accordingly. These colors are
  707. ; obtained from the color table pointed to by 'work'.
  708.  
  709. SetBGColor          ANOP
  710.                     jsr WindowActive    ; drawing an inactive window?
  711.                     beq Inact1          ; yes, set the right color
  712.  
  713.                     ldy #otBarColor     ; set the background color
  714.                     lda [<work],y
  715.                     and #%00001111      ; in bits 3-0
  716.                     pha
  717.                     bra SetIt1
  718.  
  719. Inact1              ANOP
  720.                     ldy #otitleColor    ; set the background color
  721.                     lda [<work],y
  722.                     xba                 ; in bits 11-8
  723.                     and #%00001111
  724.                     pha
  725.  
  726. SetIt1              ANOP
  727.                     _SetSolidPenPat
  728.                     rts
  729.  
  730.  
  731. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  732. ;
  733. ; We are about to draw the title in the title bar. This routine gets
  734. ; and sets the color for that based on the entry in the color table
  735. ; pointed to by 'work'.
  736.  
  737. SetTitleColor       ANOP
  738.                     jsr WindowActive    ; is this an inactive window?
  739.                     beq Inact2          ; yes
  740.  
  741.                     ldy #otitleColor    ; set the text color
  742.                     lda [<work],y
  743.                     and #%00001111      ; in bits 3-0
  744.                     pha
  745.                     bra SetIt2
  746.  
  747. Inact2              ANOP
  748.                     ldy #otitleColor    ; set the text color
  749.                     lda [<work],y
  750.                     lsr a               ; in bits 7-4
  751.                     lsr a
  752.                     lsr a
  753.                     lsr a
  754.                     and #%00001111
  755.                     pha
  756.  
  757. SetIt2              ANOP
  758.                     _SetForeColor
  759.                     rts
  760.  
  761.  
  762. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  763. ;
  764. ; Short utility routine that returns z=1 if the window is active
  765. ; and z=0 if not.
  766. ;
  767.  
  768. WindowActive        ANOP
  769.                     ldy #owFrame
  770.                     lda [<theWindow],y
  771.                     and #fHilited       ; return z=1 if active window
  772.                     rts
  773.  
  774. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  775. ;
  776. ; Local Data Storage
  777. ;
  778.  
  779. TitlePtr            ds 4
  780. XPos                ds 2
  781. OldFont             ds 4                ; holds old font when we switch to
  782. *                                       ; the Window Manager font
  783.                     end
  784.